<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <script src="/libs/react.development.js"></script>
    <script src="/libs/react-dom.development.js"></script>
    <!-- 对 props 的类型做限制引入这个 -->
    <script src="/libs/prop-types.js"></script>
    <script src="/libs/babel.min.js"></script>
  </head>
  <body>
    <div id="root"></div>
    <script type="text/babel">
      class List extends React.Component {
        // 对 props 的类型做限制
        static propTypes = {
          name: PropTypes.string.isRequired,
        };
        static defaultProps = {
          sex: "男",
        };

        render() {
          const { name, age, sex } = this.props;
          return (
            <ul>
              <li>{name}</li>
              <li>{age}</li>
              <li>{sex}</li>
            </ul>
          );
        }
      }

      ReactDOM.render(
        <List name="小王" age="12" />,
        document.getElementById("root")
      );
    </script>
  </body>
</html>
